//HJ52 计算字符串的编辑距离
import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNext()) { // 注意 while 处理多个 case
            char[] arr1 = in.next().toCharArray();
            char[] arr2 = in.next().toCharArray();
            int len1 = arr1.length;
            int len2 = arr2.length;
            int[][] dp = new int[len1+1][len2+1];
            for (int i = 0; i <= len2; i++) {
                dp[0][i] = i;
            }
            for (int i = 0; i <= len1; i++) {
                dp[i][0] = i;
            }
            for (int i = 1; i <= len1; i++) {
                for (int j = 1; j <= len2; j++) {
                    if (arr1[i-1] == arr2[j-1]) {
                        dp[i][j] = dp[i-1][j-1];
                    } else {
                        dp[i][j] = Math.min(dp[i-1][j], Math.min(dp[i-1][j-1], dp[i][j-1])) + 1;
                    }
                }
            }
            System.out.println(dp[len1][len2]);
        }
    }
}